package cn.cqie.attendance.manager.controller;

import cn.cqie.attendance.common.util.Page;
import cn.cqie.attendance.common.util.PageBean;
import cn.cqie.attendance.manager.pojo.AdminClasses;
import cn.cqie.attendance.manager.pojo.AdminClassesAdd;
import cn.cqie.attendance.manager.pojo.AdminClassesSerch;
import cn.cqie.attendance.manager.service.AdminClassesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 697
 * @date 2021/6/18 17:17
 */
@RestController
@Api(tags = "管理员端-班级信息管理模块")
@RequestMapping("/admin/classes")
public class AdminClassesController {

    @Autowired
    private AdminClassesService adminClassesService;

    /**
     * 查询所有班级信息 可模糊查询/组合查询
     * @param adminClassesSerch
     * @param pageSize    每一页的数量
     * @param pageNum 当前页
     * @return
     */
    @GetMapping("/queryAllClassesInfo")
    @ApiOperation("查询所有班级信息 可模糊查询/组合查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "className", value = "班级名(1890004)", required = false),
            @ApiImplicitParam(name = "collegeName", value = "学院名(软件学院)", required = false),
            @ApiImplicitParam(name = "gradeName", value = "年级名(2018)", required = false),
            @ApiImplicitParam(name = "majorName", value = "专业名(软件工程)", required = false),
            @ApiImplicitParam(name = "teacherName", value = "班主任名字(刘阳)", required = false),
            @ApiImplicitParam(name = "status", value = "课程状态(0未结业1已结业)", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每一页的数量(10)", required = false),
            @ApiImplicitParam(name = "pageNum", value = "当前页(1)", required = false)})
    public PageBean<AdminClasses> queryAllClassesInfo(AdminClassesSerch adminClassesSerch, Integer pageSize, Integer pageNum){
        return adminClassesService.queryAllClassesInfo(adminClassesSerch,pageSize,pageNum);
    }


    /**
     * 新增班级信息
     * @param adminClassesAdd
     * @return
     */
    @PostMapping("/addClasses")
    @ApiOperation("新增班级信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "className", value = "班级名(1890004)", required = true),
            @ApiImplicitParam(name = "collegeId", value = "学院Id(7)", required = true),
            @ApiImplicitParam(name = "gradeId", value = "年级Id(1)", required = true),
            @ApiImplicitParam(name = "majorId", value = "专业Id(4)", required = true),
            @ApiImplicitParam(name = "teacherId", value = "班主任Id(1)", required = true),
            @ApiImplicitParam(name = "status", value = "课程状态(0未结业1已结业)", required = true)})
    public Page<AdminClasses> addClasses(AdminClassesAdd adminClassesAdd){
        return adminClassesService.addClasses(adminClassesAdd);
    }


    /**
     * 根据ID查询班级信息
     * @param id
     * @return
     */
    @GetMapping("/queryClassInfoById")
    @ApiOperation("根据ID查询班级信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "班级id(1)", required = true)})
    public Page<AdminClasses> queryClassesInfoById(Integer id){
        return adminClassesService.queryClassesInfoById(id);
    }


    /**
     * 根据ID修改班级信息
     * @param adminClassesAdd
     * @param id id
     * @return
     */
    @PostMapping("/updateClassesInfoById")
    @ApiOperation("根据ID修改班级信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "className", value = "班级名(1890004)", required = true),
            @ApiImplicitParam(name = "collegeId", value = "学院Id(7)", required = true),
            @ApiImplicitParam(name = "gradeId", value = "年级Id(1)", required = true),
            @ApiImplicitParam(name = "majorId", value = "专业Id(4)", required = true),
            @ApiImplicitParam(name = "teacherId", value = "班主任Id(1)", required = true),
            @ApiImplicitParam(name = "classId", value = "班级Id(1)", required = true),
            @ApiImplicitParam(name = "status", value = "课程状态(0未结业1已结业)", required = true)})
    public Page<AdminClasses> updateClassesInfoById(AdminClassesAdd adminClassesAdd){
        return adminClassesService.updateClassesInfoById(adminClassesAdd);
    }
}
